package com.hsxshop.model;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import java.util.List;

/**
 * Created by wangchongya on 17/4/26.
 */
public class HelloWorld {

    private static final EntityManagerFactory emf;

    static {
        emf = Persistence.createEntityManagerFactory("org.hibernate.default.jpa");
    }

    public static void main(String args[]) {
        System.out.println("Hello World1!");
        EntityManager em = emf.createEntityManager();
        Query query = em.createQuery("from User");

        List<User> list= query.getResultList();
        System.out.println("size:"+list.size());
        for (int i = 0; i < list.size(); i++) {

            User user=list.get(i);
            System.out.println("id:"+user.getId());
        }

    }

}
